There is considerable interest in tools that translate a programming language description of an electronic circuit into a hardware description that can be readily implemented as hardware. Presently, tools exist that are capable of translating program code written using an imperative programming language, such as C, into a hardware description language (HDL), such as the Very high-speed integrated circuit Hardware Description Language (VHDL) or VERILOG. The HDL representation of the electronic circuit can then be implemented for an integrated circuit using a standard implementation design flow. For example, the HDL representation can be synthesized, mapped, placed, and routed for a programmable logic device (PLD), such as a field programmable gate array (FPGA).
In some instances, it is desirable to use a program language description to model a hardware component having internal states, such as a state machine. Various imperative programming languages allow persistent variables. A “persistent variable” is a variable that can retain it value between difference calls to a function in which the variable is defined. For example, in the C programming language, a variable of a function can be declared as static to be persistent. A function having persistent variables can model a single instance of a hardware component having internal states.
Using a persistent variable in a trivial manner, however, does not properly model multiple instantiations of an electronic circuit. For example, to implement two instances of a hardware accumulator, two sets of states should be retained (one set for each instance). In traditional programming language semantics, however, two calls to a function designed to model an accumulator will share a single persistent variable. Accordingly, there exists a need in the art for a method and apparatus for modeling multiple instances of an electronic circuit using an imperative programming language description.